feat: manifest-based cache with intent-based API#23
Merged
liamcervante merged 3 commits intomainfrom Mar 13, 2026
Merged
Conversation
Introduce a manifest (manifest.json) that indexes all cache entries, replacing the old approach of scanning individual JSON files on disk. Key changes: - Session ID no longer auto-detected from parent process ID (unreliable with AI agents that spawn new shells per command) - Three-tier session model: explicit INFRACOST_SESSION_ID (skips TTL), TERM_SESSION_ID fallback (respects TTL), and path+TTL only - Manifest uses two maps: Entries (path hash → metadata) for O(1) path lookups, and Sessions (session ID → cache key) for O(1) session lookups - Read/ReadLatest return *format.Output directly instead of *Entry wrapper - Stale session mappings (>24h) pruned on save to prevent unbounded growth - Manifest singleton moved from package-level var to Config struct
owenrumney
approved these changes
Mar 13, 2026
Replace Read/ReadLatest/Previous with three intent-based functions: - ForPath(path): exact path lookup with TTL and freshness checks - Latest(allowStale): most recent entry within TTL, no session logic - ReadFile(path): raw JSON file, bypasses cache Remove session tracking entirely (SessionID, TermSessionID, Sessions map, session pruning). Terminal session IDs were unreliable across different terminal emulators and agent environments. The Latest function now handles the price command's temp directory case by simply returning the most recent cached entry.
owenrumney
reviewed
Mar 13, 2026
owenrumney
approved these changes
Mar 13, 2026
Member
owenrumney
left a comment
There was a problem hiding this comment.
approval stands - one clarifying question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
manifest.json) using a map for O(1) lookups by path hashForPath(path): exact path lookup with TTL and freshness checks (used byinspect <path>)Latest(allowStale): returns the most recent entry within TTL (used byinspectwith no args, and byscan/pricefor diffing)ReadFile(path): reads a raw JSON file, bypassing the cache entirely (used byinspect --file)INFRACOST_SESSION_ID,TERM_SESSION_ID, session maps, session pruning) — terminal session IDs were unreliable across different terminal emulators and agent environmentspricecommand's temporary directory case is handled byLatest(true)which simply returns the most recent cached entry regardless of pathTest plan
inspect.go,scan.go,price.go) updated and build passes